﻿@{
    Layout = "~/Areas/Admin/Views/Shared/AdminLayout.cshtml";
}

<table class="edit_table">
    <tr>
        <td><label>旧密码</label></td>
        <td><input type="password" id="pwd" name="pwd" style="width: 300px;" /></td>
    </tr>
    <tr>
        <td><label>新密码</label></td>
        <td><input type="password" id="newpwd" name="newpwd" style="width: 300px;" /></td>
    </tr>
    <tr>
        <td><label>确认密码</label></td>
        <td><input type="password" id="qpwd" name="qpwd" style="width: 300px;" /></td>
    </tr>
    <tr>
        <td colspan="2">
            <div class="botton" style="margin-left: 50px;" onclick="edit()">保存</div>
            <div class="botton" style="margin-left: 50px;" onclick="history.go(-1)">取消</div>
        </td>
    </tr>
</table>
<script>
    function edit() {
        var pwd = $("#pwd").val();
        if (pwd.trim() == "") {
            alert("请输入密码！");
            return false;
        }
        if (pwd.length > 16 || pwd.length < 6) {
            alert("密码必须大于6位小于16位！");
            return false;
        }
        var newpwd = $("#newpwd").val();
        if (newpwd.trim() == "") {
            alert("请输入密码！");
            return false;
        }
        if (newpwd.length > 16 || newpwd.length < 6) {
            alert("密码必须大于6位小于16位！");
            return false;
        }
        var qpwd = $("#qpwd").val();
        if (newpwd != qpwd) {
            alert("两次输入密码不一致！");
            return false;
        }

        $.post("@Url.Action("EditPassword")", { password: pwd, newpwd: newpwd }, function (row) {
            if (row > 0) {
                alert("密码修改成功！");
            } else {
                alert("操作失败！");
            }
        });
    }

</script>
